Unlike addition and subtraction, which maintained $O(n+m)$ linearity through merging, polynomial multiplication requires a distinct, more computationally intensive approach.
- To find the product $S(x) = P(x) \times R(x)$, we must apply the distributive property, multiplying every term in $P(x)$ by every term in $R(x)$.
- This requirement translates directly into a nested loop structure.
- If $P(x)$ has $n$ terms and $R(x)$ has $m$ terms, the generation of all intermediate terms requires $n \times m$ fundamental operations.
- This results in a worst-case time complexity of $O(n \cdot m)$.
Multiplication Procedure
- Use the outer pointer `p` to iterate through all $n$ nodes of $P(x)$.
- For each node in $P(x)$, use the inner pointer `q` to iterate through all $m$ nodes of $R(x)$.
- For the pair $(p, q)$, the resulting Polynomial_Term has:
- New Coefficient: $coeff_p \times coeff_q$
- New Exponent: $exp_p + exp_q$
- The final step (not shown here) involves combining all the resulting $O(n \cdot m)$ intermediate terms, which may require sorting and merging.